
package org.springframework.beans.factory.config;

import org.springframework.beans.BeanMetadataElement;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.core.AttributeAccessor;
import org.springframework.lang.Nullable;

public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {

	String SCOPE_SINGLETON = "singleton";

	String SCOPE_PROTOTYPE = "prototype";

	int ROLE_APPLICATION = 0;

	int ROLE_SUPPORT = 1;

	int ROLE_INFRASTRUCTURE = 2;

	void setParentName(@Nullable String parentName);

	@Nullable
	String getParentName();// 获取父BeanDefinition,主要用于合并

	void setBeanClassName(@Nullable String beanClassName);

	@Nullable
	String getBeanClassName();

	// Bean的作用域，不考虑web容器，主要两种，单例/原型
	void setScope(@Nullable String scope);

	@Nullable
	String getScope();

	void setLazyInit(boolean lazyInit);

	// 是否进行懒加载
	boolean isLazyInit();

	// 是否需要等待指定的bean创建完之后再创建
	void setDependsOn(@Nullable String... dependsOn);

	@Nullable
	String[] getDependsOn();

	// 是否作为自动注入的候选对象
	void setAutowireCandidate(boolean autowireCandidate);

	boolean isAutowireCandidate();

	// 是否作为主选的bean
	void setPrimary(boolean primary);

	boolean isPrimary();

	// 创建这个bean的类的名称
	void setFactoryBeanName(@Nullable String factoryBeanName);

	@Nullable
	String getFactoryBeanName();

	void setFactoryMethodName(@Nullable String factoryMethodName);

	@Nullable
	String getFactoryMethodName();

	// 构造函数的参数
	ConstructorArgumentValues getConstructorArgumentValues();

	default boolean hasConstructorArgumentValues() {
		return !getConstructorArgumentValues().isEmpty();
	}

	// setter方法的参数
	MutablePropertyValues getPropertyValues();

	default boolean hasPropertyValues() {
		return !getPropertyValues().isEmpty();
	}

	boolean isSingleton();

	boolean isPrototype();

	boolean isAbstract();

	int getRole();

	@Nullable
	String getDescription();

	@Nullable
	String getResourceDescription();

	@Nullable
	BeanDefinition getOriginatingBeanDefinition();// cglib代理前的BeanDefinition
}
